home *** CD-ROM | disk | FTP | other *** search
- Path: newshost.lanl.gov!tanmoy
- From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
- Newsgroups: comp.lang.c
- Subject: Re: Please help ?!
- Date: 23 Jan 1996 16:23:20 GMT
- Organization: Los Alamos National Laboratory
- Message-ID: <TANMOY.96Jan23092320@qcd.lanl.gov>
- References: <4dm889$3hs@neptunus.pi.net> <4drnv1$cr@news.iag.net>
- <4dvrk4$f2d@news.xs4all.nl>
- NNTP-Posting-Host: qcd.lanl.gov
- Mime-Version: 1.0
- Content-Type: text
- In-reply-to: Gertjan Klein's message of 22 Jan 1996 11:15:16 GMT
-
- --text follows this line--
- In article <4dvrk4$f2d@news.xs4all.nl> Gertjan Klein
- <gklein@xs4all.nl> writes:
- <snip>
- int c = '\0';
-
- printf("Character %sfound in string.\n",
- strchr(" /-", c) ? "" : "not ");
- return 0;
- }
-
- ... displays "Character found in string." whether I include the '\0'
- or not. The basic question is, is the terminating zero regarded part of
- the string here? My implementation's strchr() seems to imply it is, but
- I'd like to know if this always the case. I couldn't find anything in
- K&R2 about how strchr() behaves when the int to search for is 0. What's
-
- The standard explicitly mentions that the termination '\0' is a part
- of the string.
-
- to keep it from first checking for the string terminator before doing
- the compare? (In either case, including the '\0' in the string wouldn't
-
- I probably didn't read enough of the message to figure this one out.
-
- make a difference, would it?)
-
- No, it doesn't make a difference. The first '\0' terminates the `string'
- for the purposes of these library functions.
-
- Cheers
- Tanmoy
-
- --
- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
- Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
- Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
- <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
- internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
- fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
-